package com.example.user.myhjjf_app.presenter;

import android.graphics.Color;
import android.util.Log;

import com.example.user.myhjjf_app.R;
import com.example.user.myhjjf_app.model.Model_Content;
import com.example.user.myhjjf_app.model.Model_guanglan;
import com.example.user.myhjjf_app.model.Model_rowCol;
import com.zhy.adapter.abslistview.ViewHolder;
import com.zhy.adapter.abslistview.base.ItemViewDelegate;

import java.util.List;
import java.util.Map;

/**
 * Created by User on 2017/9/3.
 */

public class Presenter_GjxXq_adapter implements ItemViewDelegate {
    Map<String,Model_guanglan.ValueBean> valueBeen;
    Map<String,Model_rowCol> nums;
    public Presenter_GjxXq_adapter(Map<String,Model_guanglan.ValueBean> valueBean, Map<String,Model_rowCol> nums){
        this.valueBeen = valueBean;
        this.nums = nums;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.listitm_gjxxq;
    }

    @Override
    public boolean isForViewType(Object item, int position) {
        return true;
    }

    @Override
    public void convert(ViewHolder holder, Object o, int position) {
        int row = position /12 +1;
        int col = position % 12 +1;

        String key = row + "-" + col;
        holder.setText(R.id.portTextView,key);
        if (valueBeen.containsKey(key)){
            Model_guanglan.ValueBean  vb= valueBeen.get(key);
            if (vb.getFrom_()!=null){
                holder.setImageResource(R.id.portImageView,R.mipmap.red_red);
            }else {
                holder.setImageResource(R.id.portImageView,R.mipmap.red_blue);
            }
        }else {
            holder.setImageResource(R.id.portImageView,R.mipmap.blue_blue);
        }
        if (nums.size()!=0){
            for (int i = 0; i < nums.size(); i++) {
                if (nums.containsKey(key)){
                    holder.setBackgroundColor(R.id.first, Color.GRAY);
                }else {
                    holder.setBackgroundColor(R.id.first, Color.WHITE);
                }
            }
        }else {
            holder.setBackgroundColor(R.id.first, Color.WHITE);
        }


    }

}
